import 'package:bxultimate/app/theme/app_theme.dart';
import 'package:bxultimate/app/theme/gaps.dart';
import 'package:bxultimate/data/store/config_store.dart';
import 'package:bxultimate/domain/home/home_data_dto.dart';
import 'package:bxultimate/widgets/mk_card_container.dart';
import 'package:bxultimate/widgets/mk_load_image.dart';
import 'package:flutter/material.dart';
import 'dart:math' as math;
class AppWorkTrend extends StatefulWidget {
  final Job job;
  final GestureTapCallback? onTap;
  const AppWorkTrend({super.key, required this.job, this.onTap});

  @override
  State<AppWorkTrend> createState() => _AppWorkTrendState();
}

class _AppWorkTrendState extends State<AppWorkTrend> {
  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: widget.onTap,
      child: MkCardContainer(
        margin: EdgeInsets.only(bottom: AppTheme.iDefaultPadding),
        padding: EdgeInsets.all(AppTheme.iDefaultPadding),
        child: Row(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            ClipRRect(
              borderRadius: BorderRadius.circular(40),
              child: MkLoadImage(
                ConfigStore.to.baseFileUrl + widget.job.userHeadImg,
                width: 40,
                height: 40,
              ),
            ),
            Gaps.hGap12,
            Expanded(
                child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text(
                  '${widget.job.userName}',
                  style: TextStyle(fontSize: 14, fontWeight: FontWeight.bold),
                ),
                Gaps.vGap4,
                Text(
                  '${widget.job.content}',
                  style: TextStyle(fontSize: 12, color: Color(0xFF606266)),
                ),
                Gaps.vGap4,
                widget.job.annexList.length > 0
                    ? Container(
                        height: (widget.job.annexList.length / 3).ceil() * 100,
                        child: GridView.count(
                          physics: NeverScrollableScrollPhysics(),
                          crossAxisCount: 3,
                          mainAxisSpacing: 8,
                          crossAxisSpacing: 8,
                          // 每行三个项
                          children: List.generate(
                            widget.job.annexList.length, // 生成9个项
                            (index) => MkLoadImage(
                              ConfigStore.to.baseFileUrl +
                                  widget.job.annexList[index].path,
                            ),
                          ),
                        ),
                      )
                    : SizedBox(),
                Gaps.vGap4,
                Text(
                  '${widget.job.publishTime}',
                  textAlign: TextAlign.right,
                  style: TextStyle(fontSize: 10, color: Color(0xFF606266)),
                ),
              ],
            ))
          ],
        ),
      ),
    );
  }
}
